import { request } from './index'

// 获得角色
export function GetRoleFnc () { 
  return request({
    url: '/roles',
    method: 'get'
  })
}

// 展示编辑角色盒子
export function ShowRoleFnc (id: number, data: {roleId: number, roleName: string, roleDesc: string}) { 
  return request({
    url: `/roles/${id}`,
    method: 'get',
    data: data
  })
}

// 修改角色
export function EditRoleFnc (id: number, data: any) { 
    return request({
        url: `/roles/${id}`,
        data: data,
        method: 'put'
    })
}

// 删除整个角色分类下的单独子分类
export function DeleteRoleChildFnc (roleID: number, rightID: number) { 
    return request({
        url: `/roles/${roleID}/rights/${rightID}`,
        method: 'delete'
    })
}

// 展示权限分配盒子
export function ShowRightFnc () { 
    return request({
      url: '/rights/tree',
      method: 'get'
    })
  }
  
  // 更新权限分配
  export function SetRightFnc (id: number, data: {rids: string}) { 
    return request({
      url: `/roles/${id}/rights`,
      method: 'post',
      data: data
    })
  }